/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UploaderView.java
 *
 * Created on 2011-05-23, 08:55:01
 */
package ytmc.uploader;

import javax.swing.JOptionPane;
import ytmc.PanelView;

/**
 *
 * @author K
 */
public class UploaderView extends PanelView
{
    private UploaderModel model;
    private UploaderController controller;
   // private AddUploadTasksView addUploadTaskView;

    /*public String getSavePath()
    {
        return addUploadTaskView.getSavePath();
    }

    public void setSavePath(String path)
    {
        addUploadTaskView.setSavePath(path);
    }

    public String getVideoTitle()
    {
        return addUploadTaskView.getVideoTitle();
    }

    public void setVideoTitle(String title)
    {
        addUploadTaskView.setVideoTitle(title);
    }

    public VideoCategory getVideoCategory()
    {
        return addUploadTaskView.getVideoCategory();
    }

    public void setVideoCategory(VideoCategory category)
    {
        addUploadTaskView.setVideoCategory(category);
    }

    public String getVideoTags()
    {
        return addUploadTaskView.getVideoTags();
    }

    public void setVideoTags(String tags)
    {
        addUploadTaskView.setVideoTags(tags);
    }

    public String getVideoDescription()
    {
        return addUploadTaskView.getVideoDescription();
    }

    public void setVideoDescription(String description)
    {
        addUploadTaskView.setVideoDescription(description);
    }*/

    /** Creates new form UploaderView */
    public UploaderView(UploaderController controller, UploaderModel model)
    {
        this.model = model;
        this.controller = controller;
        //this.addUploadTaskView = new AddUploadTasksView(controller);
        
        initComponents();

        uploadsTable.setModel(model);
        uploadsTable.getColumn("Nazwa pliku").setMinWidth(100);
        uploadsTable.getColumn("Kategoria").setMinWidth(80);
        uploadsTable.getTableHeader().setReorderingAllowed(false);
    }

    public void showMessage(String message)
    {
        JOptionPane.showMessageDialog(this, message);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        uploadsTable = new javax.swing.JTable();
        jToolBar1 = new javax.swing.JToolBar();
        addUploadBtn = new javax.swing.JButton();
        removeUploadBtn = new javax.swing.JButton();
        startUploadBtn = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(720, 400));

        uploadsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Nazwa pliku", "Status", "Rozmiar", "Postęp", "Prędkość", "Szacowane"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        uploadsTable.setGridColor(new java.awt.Color(204, 204, 204));
        uploadsTable.setInheritsPopupMenu(true);
        jScrollPane1.setViewportView(uploadsTable);

        jToolBar1.setFloatable(false);
        jToolBar1.setOrientation(1);
        jToolBar1.setRollover(true);
        jToolBar1.setMinimumSize(new java.awt.Dimension(40, 2));

        addUploadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/add24.png"))); // NOI18N
        addUploadBtn.setToolTipText("Dodaj wideo do wysłania");
        addUploadBtn.setFocusable(false);
        addUploadBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        addUploadBtn.setMaximumSize(new java.awt.Dimension(40, 31));
        addUploadBtn.setMinimumSize(new java.awt.Dimension(40, 31));
        addUploadBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        addUploadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addUploadBtnActionPerformed(evt);
            }
        });
        jToolBar1.add(addUploadBtn);

        removeUploadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/delete24.png"))); // NOI18N
        removeUploadBtn.setToolTipText("Usuń zaznaczone wideo");
        removeUploadBtn.setFocusable(false);
        removeUploadBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        removeUploadBtn.setMaximumSize(new java.awt.Dimension(40, 31));
        removeUploadBtn.setMinimumSize(new java.awt.Dimension(40, 31));
        removeUploadBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        removeUploadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeUploadBtnActionPerformed(evt);
            }
        });
        jToolBar1.add(removeUploadBtn);

        startUploadBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/play24.png"))); // NOI18N
        startUploadBtn.setToolTipText("Uruchom wysyłanie");
        startUploadBtn.setFocusable(false);
        startUploadBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        startUploadBtn.setMaximumSize(new java.awt.Dimension(40, 31));
        startUploadBtn.setMinimumSize(new java.awt.Dimension(40, 31));
        startUploadBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        startUploadBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startUploadBtnActionPerformed(evt);
            }
        });
        jToolBar1.add(startUploadBtn);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void addUploadBtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_addUploadBtnActionPerformed
    {//GEN-HEADEREND:event_addUploadBtnActionPerformed
        //addUploadTaskView.clear();
        //addUploadTaskView.setVisible(true);
        controller.showAddUploadTask();
    }//GEN-LAST:event_addUploadBtnActionPerformed

    private void removeUploadBtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_removeUploadBtnActionPerformed
    {//GEN-HEADEREND:event_removeUploadBtnActionPerformed
        controller.removeTask(uploadsTable.getSelectedRow());
    }//GEN-LAST:event_removeUploadBtnActionPerformed

    private void startUploadBtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_startUploadBtnActionPerformed
    {//GEN-HEADEREND:event_startUploadBtnActionPerformed
        controller.startTask(uploadsTable.getSelectedRow());
    }//GEN-LAST:event_startUploadBtnActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addUploadBtn;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton removeUploadBtn;
    private javax.swing.JButton startUploadBtn;
    private javax.swing.JTable uploadsTable;
    // End of variables declaration//GEN-END:variables
}
